package com.yqw.geotoolsguava.eventbus;

import java.util.HashMap;
import java.util.concurrent.ConcurrentMap;

import com.google.common.collect.Maps;

/**
 * 入口
 *
 * @Date: 2020-08-28 16:24
 * @since: 1.0
 */
public class BasicEventMain {
    /**
     * 入口函数
     *
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        final BasicEventBus eventBus = new BasicEventBus();
        BasicEventSubscriber subscriber = new BasicEventSubscriber();
        eventBus.register(subscriber);
        eventBus.register(subscriber);
        // 模拟消息发送
        Thread eventTread = new Thread(new Runnable() {
            public void run() {
                for (int i = 0; i < 100; i++) {
                    eventBus.post(new BasicEvent(i));
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        eventTread.start();
        //防止主程序退出
        eventTread.join();
    }
}
